Option Strict Off
Option Explicit On
Imports MMUtil.clsGeneral
Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Friend Class frmReason
	Inherits System.Windows.Forms.Form
	
	Private Sub cmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.Click
		txtReason.Text = ""
		gReason = ""
		Me.Close()
	End Sub
	
	Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click
		gReason = txtReason.Text
		Me.Close()
	End Sub
	
	'UPGRADE_WARNING: Form event frmReason.Activate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
	Private Sub frmReason_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
		vasView.Focus()
	End Sub
	
	Private Sub frmReason_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		'Me.Height = 3345
		txtReason.Text = ""
		gReason = ""
		
		SQL = "Select ViewCode, Comment1 From Promise " & CR & "Where HID = '" & gHosInfo.HID & "'  "
		If gToggle = 10 Then
			SQL = SQL & "  and ViewCode like '4%' "
		ElseIf gToggle = 11 Then 
			SQL = SQL & "  and ViewCode like '5%' "
		End If
		res = db_select_Vas(SQL, vasView)
	End Sub
	
	Private Sub frmReason_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		'UPGRADE_NOTE: Object frmReason may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		Me.Dispose()
	End Sub
	
	'UPGRADE_WARNING: Event txtCode.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub txtCode_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtCode.TextChanged
		If txtCode.Text = "" Then
			Exit Sub
		End If
		
		SQL = "Select Comment1 From Promise " & CR & "Where HID = '" & gHosInfo.HID & "' and ViewCode = '" & Trim(txtCode.Text) & "' "
		res = db_select_Text(SQL, txtReason)
	End Sub
	
	Private Sub txtReason_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtReason.Enter
		SetIME(Me.Handle.ToInt32, True)
	End Sub
	
	Private Sub vasView_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxFPSpread._DSpreadEvents_ClickEvent) Handles vasView.ClickEvent
		txtCode.Text = Trim(GetText(vasView, eventArgs.Row, 1))
		txtReason.Text = Trim(GetText(vasView, eventArgs.Row, 2))
	End Sub
	
	Private Sub vasView_KeyDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxFPSpread._DSpreadEvents_KeyDownEvent) Handles vasView.KeyDownEvent
		If eventArgs.KeyCode = System.Windows.Forms.Keys.Return Then
			txtCode.Text = Trim(GetText(vasView, vasView.ActiveRow, 1))
			txtReason.Text = Trim(GetText(vasView, vasView.ActiveRow, 2))
			If Trim(txtReason.Text) <> "" Then cmdOK_Click(cmdOK, New System.EventArgs())
		End If
	End Sub
End Class